package com.yidu.service.impl;

import com.yidu.entity.VipTb;
import com.yidu.dao.VipTbDao;
import com.yidu.service.VipTbService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (VipTb)表服务实现类
 *
 * @author JiuYue
 * @since 2021-07-29 16:28:36
 */
@Service("vipTbService")
public class VipTbServiceImpl implements VipTbService {
    @Resource
    private VipTbDao vipTbDao;

    /**
     * 通过ID查询单条数据
     *
     * @param vid 主键
     * @return 实例对象
     */
    @Override
    public VipTb queryById(Integer vid) {
        return this.vipTbDao.queryById(vid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<VipTb> queryAllByLimit(int offset, int limit) {
        return this.vipTbDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param vipTb 实例对象
     * @return 实例对象
     */
    @Override
    public VipTb insert(VipTb vipTb) {
        this.vipTbDao.insert(vipTb);
        return vipTb;
    }

    /**
     * 修改数据
     *
     * @param vipTb 实例对象
     * @return 实例对象
     */
    @Override
    public VipTb update(VipTb vipTb) {
        this.vipTbDao.update(vipTb);
        return this.queryById(vipTb.getVid());
    }

    /**
     * 通过主键删除数据
     *
     * @param vid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer vid) {
        return this.vipTbDao.deleteById(vid) > 0;
    }

    @Override
    public VipTb findLogin(VipTb param) {
        VipTb po=vipTbDao.findLogin(param);
        return po;
    }

    @Override
    public VipTb findByName(String vname) {
        System.out.println(vname);
        return this.vipTbDao.findByName(vname);
    }
}
